rpgdevfandomcom-20200213-history
Rpg.js
__TOC__ rpg.js This file contains the rpg class definition. See each method respectively for more detailed information. callMap This method calls a map prepared with "prepareMap". @method callMap @param {String} name Name calling map @return {Boolean} Return false if no map is found. loadMap This method loads a map with the player on the specified position. @method loadMap @param {String|Object} filename Name of file in the folder "Data/Maps". File format: JSON. We can define a custom path if the parameter is an object : path {String} : Link to map noCache {Boolean} (optional): if true, the map data is not cached. "false" by defaultExample : rpg.loadMap({path: "../dir/map.php", noCache: true}, {tileset: "town.png"}, function() { console.log("the map is loaded"); }); @param {Object} propreties Map Properties. The object is : tileset {String} (Optional if map encoded in base64): Name of file in the folder "Graphics/Tilesets", autotiles (Optional): Array Autotiles. The values are the names of files in the folder "Graphics/Autotiles". Each image is divided into 48 tiles with a specific ID, bgm {String|Object} (Optional): Background music that plays automatically. If object : {mp3: "name", ogg: "name"} bgs {String|Object} (Optional): Background sound that plays automatically. If object : {mp3: "name", ogg: "name"} events {Array|Object} (Optional): Array of events to load. The values are the names of files in the "Data/Events". We can define a custom path if the element is an object : path {String} : Link to event noCache {Boolean} (optional): if true, the event data is not cached. "false" by default * @param {Function} isLoad (Optional) Callback Function when the map is loaded autoDisplay {Boolean} (optional): Directly displays the map after it is loaded. If false, see the method "displayMap()" to display the map manually. true by default transfert {Array} (optional): Transfer a player to another map when he arrives at a specific position. Array containing objects of each tile transferable : x: {Integer} X starting position for the transfer y: {Integer} Y starting position for the transfer map: {String} Map name x_final: {Integer} X position of arrival y_final: {Integer} Y position of arrival dx {Integer} (optional): Number of horizontal tiles that can transfer the player dy {Integer} (optional): Number of vertical tiles that can transfer the player parallele {Boolean} (optional): Each tile transfer the player on the same coordinates X or Y direction {String} (optional): up|bottom|left|right The direction of the player to be able to transfer callback {Function} (optional): Callback function before transferring to another map. If the function returns false, the player will not be transferred. player {Object} (Optional): Properties player : x {Integer}: X Position y {Integer}: Y Position direction {String} (optional): up|bottom|left|right; Departure Direction filename {String} : Filename regX {Integer} (optional): The x offset for this display object's registration point. regY {Integer} (optional): The y offset for this display object's registration point speed {Integer} (optional): Speed nbSequenceX {Integer} (optional): Sequence number of the image on the X axis nbSequenceY {Integer} (optional): Sequence number of the image on the Y axis speedAnimation {Integer} (optional): Animation speed no_animation {Boolean} (optional): Don't display the animation actionBattle {Object} (optional): see "addEvent()" actions {Array} (optional): Actions (see "addActions()") @param {Function} isLoad (Optional) Callback Function when the map is loaded prepareMap This method prepares a map that can be loaded with "callMap". Parameter "player" is not necessary if already loaded on another map. @method prepareMap @param {String} filename Filename @param {Object} propreties Map Properties. See the method "loadMap" for more information @param {Function} isLoad (Optional) Callback Function when the map is loaded Category:RPGJS